/**
* @file		Panel.Main.ixx
* @brief	主界面
*
*
* @version	1.0
* @author	lveyou
* @date		22-06-02
*
*/
export module Panel.Main;

import DND;

import DefOrder;
import ResMgr;

export class PanelMain : public UI::Panel
{
public:
	PanelMain()
	{
		SetOrder(DefOrder::UI);

		//
		_grpBg = CreateGroup();
		_grpBg->SetOrder(DefOrder::BG);
		{
			auto* spr = UI::Sprite::Create(
				g_factory->CreateSpriteDefault(),
				UI::Sprite::Type::FILL_WINDOW);
			_grpBg->Add(&spr->_cpts);
		}

		//
		_grpTtile = CreateGroup({}, { 0.5, 0.25 });
		{
			auto* txt = UI::Text::Create(g_factory->CreateTextPointer(1, 100));
			txt->GetText()->SetColor(createColor(ColorDef::BLACK));
			txt->SetLang("main", "game_name");
			txt->SetElementData(Horizontal::CENTER, Vertical::CENTER);
			_grpTtile->Add(&txt->_cpts);
		}

		//
		_grpMain = CreateGroup({}, { 0.5, 0.4 },
			Locator{ {}, {0.0, 32.0}, Locator::Layout::COLUMN});
		{
			vector<string_view> mul = g_lang->GetTagNameAll("main", "menu");
			for (auto& iter : mul)
			{
				auto* btn = g_res->CreateButtonNormal();
				btn->SetLang("main", iter);
				btn->SetElementData(Horizontal::CENTER, Vertical::CENTER);
				_grpMain->Add(&btn->_cpts);
			}
			
		}
	}

	size_t GetIndexMenu() { return _grpMain->GetIndexCilck(); }
private:
	UI::Group* _grpBg;
	UI::Group* _grpTtile;
	UI::Group* _grpMain;

};
